import Blockly from 'blockly/core'
import 'blockly/python_compressed'
import 'blockly/blockly_compressed'
import 'blockly/blocks_compressed'

Blockly.Blocks.class_procedure = {
  init: function () {
    this.appendDummyInput()
      .appendField('define class')
      .appendField(new Blockly.FieldTextInput('myClass'), 'CLASSNAME')
    this.appendStatementInput('METHODS').appendField('statements')
    this.setInputsInline(false)
    this.setPreviousStatement(true, null)
    this.setNextStatement(true, null)
    this.setColour(15)
    this.setTooltip('class关键词')
    this.setHelpUrl('')
  }
}

Blockly.Python.class_procedure = function (block) {
  const textClassName = block.getFieldValue('CLASSNAME')
  const statementsMethods = Blockly.Python.statementToCode(block, 'METHODS')
  let code = 'class ' + textClassName + ':' + '\n'
  code += statementsMethods
  return code
}

export default Blockly
